<?php
    $error = false;
    if($this->Session->check('process_error')){
        if($this->Session->read('process_error') == 'yes'){
            $error = true;
        }
        $controller->Session->delete('process_error');
    }
?>
<?php
    $flash_msg = $this->Session->read('Message');
    if(isset($flash_msg['flash'])){
?>
    <div id="loginmsg" style="">
        <?php
            if($error){
                echo $this->Message->msg('Profile Update',$this->Session->flash(),'error',true);
            }
            else{
                echo $this->Message->msg('Profile Update',$this->Session->flash(),'success',true);
            }
        ?>
    </div>
<?php
    }
    if($authuser['first_time_pass_changed'] == 'No'){
        echo $this->Message->msg('Important','Please Change your password!','error', false);
    }
?>
<div id="cart" class="row-fluid">
    <div class="span12">
        <?php echo $this->Form->create('StudentUser', array('id' => 'form', 'class' => 'form form-horizontal', 'inputDefaults' => array('label' => false,'div' => false)));?>
        <fieldset>
            <legend>Edit your profile information, <?php echo $authuser['fname'];?> ! </legend>
            <div class="control-group">
                <label class="control-label" for="username">* Username:</label>
                <div class="controls">
                    <?php echo $authuser['username'] ;?>
                    <?php /*echo $this->Form->input('username', array('id'=>'username', 'class' => 'input-block-level', 'value'=>$authuser['username'],'placeholder'=>'Username','div' => false, 'label' => false,)); */?>
                </div>
            </div>

            <div class="control-group cheque_row">
                <label class="control-label" for="password">Password:</label>
                <div class="controls">
                    <?php echo $this->Form->input('password', array('type'=>'password','id'=>'password', 'class' => 'input-block-level', 'placeholder'=>'Password','div' => false, 'label' => false,)); ?>
                </div>
            </div>

            <div class="control-group cheque_row">
                <label class="control-label" for="cellphone">Phone Number:</label>
                <div class="controls">
                    <?php echo $this->Form->input('cellphone', array('id'=>'cellphone', 'class' => 'input-block-level', 'value'=>$authuser['cellphone'], 'placeholder'=>'233-123456789','required'=>'required','div' => false, 'label' => false,)); ?>
                </div>
            </div>

            <div class="control-group">
                <label class="control-label" for="email">Email:</label>
                <div class="controls">
                    <?php echo $this->Form->input('email', array('id'=>'email', 'class' => 'input-block-level', 'value'=>$authuser['email'],'placeholder'=>'example@you.com','required'=>'required','div' => false, 'label' => false,)); ?>
                </div>
            </div>
            <?php
                if($edit_other_profile == 'Yes'){
            ?>
                <div class="control-group">
                    <label class="control-label" for="fname">First Name:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('fname', array('id'=>'fname', 'class' => 'input-block-level', 'value'=>$profile['fname'],'required'=>'required','div' => false, 'label' => false,)); ?>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="mname">Middle Name:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('mname', array('id'=>'mname', 'class' => 'input-block-level', 'value'=>$profile['mname'],'div' => false, 'label' => false,)); ?>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="lname">Last Name:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('lname', array('id'=>'lname', 'class' => 'input-block-level', 'value'=>$profile['lname'],'required'=>'required','div' => false, 'label' => false,)); ?>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="email">Gender:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('gender', array('id'=>'gender', 'class' => 'input-block-level', 'options'=>array('M'=>'M','F'=>'F'), 'default'=>$profile['gender'],'div' => false, 'label' => false,)); ?>
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="date_of_admission">Date of Admission:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('date_of_admission', array('id'=>'date_of_admission', 'class' => 'input-block-level', 'value'=>$profile['date_of_admission'],'placeholder'=>'AUG2013','required'=>'required','div' => false, 'label' => false,)); ?>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="date_of_completion">Date of Completion:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('date_of_completion', array('id'=>'date_of_completion', 'class' => 'input-block-level', 'value'=>$profile['date_of_completion'],'placeholder'=>'AUG2013','required'=>'required','div' => false, 'label' => false,)); ?>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="nationality">Nationality:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('nationality', array('id'=>'nationality', 'class' => 'input-block-level', 'default'=>$profile['nationality'],'options'=>$countries,'div' => false, 'label' => false,)); ?>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="homephone">Home Phone Number:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('homephone', array('id'=>'homephone', 'class' => 'input-block-level', 'value'=>$profile['homephone'],'div' => false, 'label' => false,)); ?>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="program_id">Program:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('program_id', array('id'=>'program_id', 'class' => 'input-block-level', 'default'=>$profile['program_id'],'options'=>$programs,'div' => false, 'label' => false,)); ?>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="level">Level:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('level', array('id'=>'level', 'class' => 'input-block-level', 'default'=>$profile['level'],'options'=>$levels,'div' => false, 'label' => false,)); ?>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="entry_level">Entry Level:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('entry_level', array('id'=>'entry_level', 'class' => 'input-block-level', 'default'=>$profile['entry_level'],'options'=>$levels,'div' => false, 'label' => false,)); ?>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="applicant_id">Applicant ID:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('applicant_id', array('id'=>'applicant_id', 'class' => 'input-block-level', 'value'=>$profile['applicant_id'],'div' => false, 'label' => false,)); ?>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="classification">Classification:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('classification', array('id'=>'classification', 'class' => 'input-block-level', 'default'=>$profile['classification'],'options'=>$classification,'div' => false, 'label' => false,)); ?>
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="graduate">Graduate:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('graduate', array('id'=>'graduate', 'class' => 'input-block-level', 'default'=>$profile['graduate'],'options'=>array('0'=>'No','1'=>'Yes'),'div' => false, 'label' => false,)); ?>
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="completed">Completed:</label>
                    <div class="controls">
                        <?php echo $this->Form->input('completed', array('id'=>'completed', 'class' => 'input-block-level', 'default'=>$profile['completed'],'options'=>array('0'=>'No','1'=>'Yes'),'div' => false, 'label' => false,)); ?>
                    </div>
                </div>
            <?php
                }
            ?>
            <?php echo $this->Form->input('id', array('id'=>'id', 'value'=>$authuser['id'],'div' => false, 'label' => false,)); ?>
        </fieldset>
        <div class="control-group">
            <label class="control-label">&nbsp;</label>
            <div class="controls">
                <button type="submit" id="update_btn" class="btn btn-primary">Update Info</button>
                <button type="reset"  id="reset_btn" class="btn">Cancel</button>
            </div>
        </div>
        <?php echo $this->Form->end();?>
    </div>
</div>

<input type="hidden" id="do-payment-url" value="<?php echo $this->Html->url(array('controller' => 'Student', 'action' => 'do_payment')); ?>" />
<input type="hidden" id="payment-url" value="<?php echo $this->Html->url(array('controller' => 'Student', 'action' => 'payments')); ?>" />

<script type="text/javascript">
    $(document).ready(function () {
        $("#cellphone").mask("999-999999999");
    });
</script>